package edu.uic.ids517;

import java.io.Serializable;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;
import java.util.Locale.Category;

import javax.annotation.PostConstruct;
import javax.faces.model.SelectItem;

public class TableListBean implements Serializable {
	
	 private String tableName;
	    private List<String> tableNames; 
	    DbaseBean dbase;
	    
	    
	    
	    public DbaseBean getDbase() {
			return dbase;
		}


		public void setDbase(DbaseBean dbase) {
			this.dbase = dbase;
		}


		public String getTableName() {
			return tableName;
		}


		public void setTableName(String tableName) {
			this.tableName = tableName;
		}


		public List<String> getTableNames() {
			return tableNames;
		}


		public void setTableNames(List<String> tableNames) {
			this.tableNames = tableNames;
		}


		 public void populateTables() throws SQLException {
	    	tableNames = getAllTables();
	    }

	
	public List<String> getAllTables() throws SQLException{

		   List<String> items = new ArrayList<String>();
		   
		   // database work
		   
		   dbase.openConnection();
		   String sqlSelectQuery = "SHOW tables ";
		   ResultSet tableRS = dbase.executeSelectSQL(sqlSelectQuery);
		   System.out.print("I am here!!!!!!!!!!!!!!!!!");
		    while(tableRS.next()){
		    	System.out.print("I am !!!!!!!!!!!!!!!!!");
		    	  items.add(tableRS.getString("Tables_in_f14g49"));
		   }
		   return items;
		}
	
	 
	
}
	
	
	
